import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

class HeadSub extends StatefulWidget {
  final String? head;
  final String? sub;

  const HeadSub({Key? key, this.head, this.sub}) : super(key: key);

  @override
  State<HeadSub> createState() => _HeadSubState();
}

class _HeadSubState extends State<HeadSub> {
  bool isAnimate = false;
  @override
  Widget build(BuildContext context) {
    return MouseRegion(
      onEnter: (event) {
        setState(() {
          isAnimate = true;
        });
      },
      onExit: (event) {
        setState(() {
          isAnimate = false;
        });
      },
      child: Container(
        width: 450,
        padding: EdgeInsets.only(left: 20.0, right: 25.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Container(
              height: 3.0,
              width: 200,
              color: Colors.black54,
            ),
            SizedBox(
              height: 10.0,
            ),
            AnimatedCrossFade(
              firstChild: Padding(
                padding: EdgeInsets.only(left: 25.0),
                child: Text(
                  widget.head!,
                  style: GoogleFonts.poppins(
                    fontSize: 35.0,
                    color: Colors.black,
                    fontWeight: FontWeight.w700,
                  ),
                ),
              ),
              secondChild: Padding(
                padding: EdgeInsets.only(left: 25.0),
                child: Text(
                  widget.head!,
                  style: GoogleFonts.poppins(
                    fontSize: 35.0,
                    color: Colors.white,
                    fontWeight: FontWeight.w700,
                  ),
                ),
              ),
              crossFadeState: !isAnimate
                  ? CrossFadeState.showFirst
                  : CrossFadeState.showSecond,
              duration: Duration(milliseconds: 300),
            ),
            Padding(
              padding: EdgeInsets.only(left: 100.0),
              child: Text(
                widget.sub!,
                style: GoogleFonts.poppins(
                  fontSize: 16.0,
                  color: Colors.black.withOpacity(0.8),
                ),
              ),
            ),
            Container(
              margin: EdgeInsets.only(left: 200.0, top: 15.0),
              height: 3.0,
              width: 200,
              color: Colors.black54,
            ),
            Container(
              margin: EdgeInsets.only(left: 150.0, top: 10.0),
              height: 3.0,
              width: 200,
              color: Colors.black54,
            ),
          ],
        ),
      ),
    );
  }
}
